﻿namespace SimbaRGVMonitor.Models
{
    class Path
    {
        public Path(string pathNo, int pathDestA, string startVertex, string endVertex)
        {
            this.pathNo = pathNo;
            this.pathDestA = pathDestA;
            this.startVertex = startVertex;
            this.endVertex = endVertex;
        }

        //====================================================================================================
        //以上是类型构造函数
        //----------------------------------------------------------------------------------------------------
        //以下是类型字段
        //====================================================================================================

        private readonly string pathNo;
        private readonly int pathDestA;
        private readonly string startVertex;
        private readonly string endVertex;

        //====================================================================================================
        //以上是类型字段
        //----------------------------------------------------------------------------------------------------
        //以下是类型属性
        //====================================================================================================

        public string PathNo
        {
            get { return pathNo; }
        }

        public int PathDestA
        {
            get { return pathDestA; }
        }

        public string StartVertex
        {
            get { return startVertex; }
        }

        public string EndVertex
        {
            get { return endVertex; }
        }

        //====================================================================================================
        //以上是类型属性
        //----------------------------------------------------------------------------------------------------
        //以下是重载操作符==及!=
        //====================================================================================================

        public static bool operator ==(Path left, Path right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(Path left, Path right)
        {
            return Equals(left, right) == false;
        }

        //====================================================================================================
        //以上是重载操作符==及!=
        //----------------------------------------------------------------------------------------------------
        //以下是重写Equals及GetHashCode
        //====================================================================================================

        public override bool Equals(object obj)
        {
            var other = obj as Path;
            return other != null &&
                other.pathNo == pathNo &&
                other.pathDestA == pathDestA &&
                other.startVertex == startVertex &&
                other.endVertex == endVertex;
        }

        public override int GetHashCode()
        {
            var hashCode = pathNo == null ? string.Empty.GetHashCode() : pathNo.GetHashCode();
            hashCode ^= pathDestA.GetHashCode();
            hashCode ^= startVertex == null ? string.Empty.GetHashCode() : startVertex.GetHashCode();
            hashCode ^= endVertex == null ? string.Empty.GetHashCode() : endVertex.GetHashCode();
            return hashCode;
        }
    }
}
